<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE CApiFFI #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Module      :  Graphics.Win32.Window</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Copyright   :  (c) Alastair Reid, 1997-2003</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- A collection of FFI declarations for interfacing with Win32.</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Graphics.Win32.Window</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">liftM</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">when</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">unless</span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromMaybe</span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Int</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Int32</span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.ForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">withForeignPtr</span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Utils</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeWith</span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Alloc</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">allocaBytes</span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Array</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">allocaArray</span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">FunPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Ptr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">castFunPtrToPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">castPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">nullPtr</span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">intPtrToPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">castPtrToFunPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">freeHaskellFunPtr</span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Storable</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">pokeByteOff</span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">CIntPtr</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HBITMAP</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HCURSOR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HDC</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HDWP</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HRGN</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">PRGN</span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HBRUSH</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HICON</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HMENU</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">prim_ChildWindowFromPoint</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">LPRECT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">RECT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">allocaRECT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peekRECT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withRECT</span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">POINT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">allocaPOINT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peekPOINT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withPOINT</span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">prim_ChildWindowFromPointEx</span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Message</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">WindowMessage</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wM_NCDESTROY</span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.IO.Unsafe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">unsafePerformIO</span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ATOM</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">maybePtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">newTString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ptrToMaybe</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">numToMaybe</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Addr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">BOOL</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">DWORD</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">INT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LONG</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LRESULT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">UINT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">WPARAM</span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HANDLE</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HINSTANCE</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LONG_PTR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPARAM</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPCTSTR</span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">LPTSTR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPVOID</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withTString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peekTString</span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">failIf</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIf_</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfFalse_</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfNull</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">maybeNum</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failUnlessSuccess</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getLastError</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">errorWin</span><span class="hs-special">)</span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-48"></span><span class="hs-comment">-- Window Class</span><span>
</span><span id="line-49"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-comment">-- The classname must not be deallocated until the corresponding class</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- is deallocated.  For this reason, we represent classnames by pointers</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- and explicitly allocate the className.</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">ClassName</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">LPCTSTR</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">-- Note: this is one of those rare functions which doesn't free all</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- its String arguments.</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="hs-identifier">mkClassName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ClassName</span><span>
</span><span id="line-61"></span><span class="hs-identifier">mkClassName</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafePerformIO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">newTString</span><span> </span><span class="hs-identifier">name</span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">ClassStyle</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-identifier">cS_VREDRAW</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-66"></span><span class="hs-identifier">cS_VREDRAW</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-67"></span><span class="hs-identifier">cS_HREDRAW</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-68"></span><span class="hs-identifier">cS_HREDRAW</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-69"></span><span class="hs-identifier">cS_OWNDC</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-70"></span><span class="hs-identifier">cS_OWNDC</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-71"></span><span class="hs-identifier">cS_CLASSDC</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-72"></span><span class="hs-identifier">cS_CLASSDC</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">64</span><span>
</span><span id="line-73"></span><span class="hs-identifier">cS_PARENTDC</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-74"></span><span class="hs-identifier">cS_PARENTDC</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-75"></span><span class="hs-identifier">cS_SAVEBITS</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-76"></span><span class="hs-identifier">cS_SAVEBITS</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2048</span><span>
</span><span id="line-77"></span><span class="hs-identifier">cS_DBLCLKS</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-78"></span><span class="hs-identifier">cS_DBLCLKS</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-79"></span><span class="hs-identifier">cS_BYTEALIGNCLIENT</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-80"></span><span class="hs-identifier">cS_BYTEALIGNCLIENT</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4096</span><span>
</span><span id="line-81"></span><span class="hs-identifier">cS_BYTEALIGNWINDOW</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-82"></span><span class="hs-identifier">cS_BYTEALIGNWINDOW</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8192</span><span>
</span><span id="line-83"></span><span class="hs-identifier">cS_NOCLOSE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-84"></span><span class="hs-identifier">cS_NOCLOSE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-85"></span><span class="hs-identifier">cS_GLOBALCLASS</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassStyle</span><span>
</span><span id="line-86"></span><span class="hs-identifier">cS_GLOBALCLASS</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16384</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-pragma">{-# LINE 78 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">WNDCLASS</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-80"></span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ClassStyle</span><span class="hs-special">,</span><span>    </span><span class="hs-comment">-- style</span><span>
</span><span id="line-81"></span><span>  </span><span class="hs-identifier">HINSTANCE</span><span class="hs-special">,</span><span>     </span><span class="hs-comment">-- hInstance</span><span>
</span><span id="line-82"></span><span>  </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HICON</span><span class="hs-special">,</span><span>   </span><span class="hs-comment">-- hIcon</span><span>
</span><span id="line-83"></span><span>  </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HCURSOR</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- hCursor</span><span>
</span><span id="line-84"></span><span>  </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HBRUSH</span><span class="hs-special">,</span><span>  </span><span class="hs-comment">-- hbrBackground</span><span>
</span><span id="line-85"></span><span>  </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">LPCTSTR</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- lpszMenuName</span><span>
</span><span id="line-86"></span><span>  </span><span class="hs-identifier">ClassName</span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- lpszClassName</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">--ToDo!</span><span>
</span><span id="line-89"></span><span class="hs-comment">--To avoid confusion with NULL, WNDCLASS requires you to add 1 to a SystemColor</span><span>
</span><span id="line-90"></span><span class="hs-comment">--(which can be NULL)</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- %fun mkMbHBRUSH :: SystemColor -&gt; MbHBRUSH</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- %code</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- %result ((HBRUSH)($0+1));</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="hs-identifier">withWNDCLASS</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WNDCLASS</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">WNDCLASS</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-96"></span><span class="hs-identifier">withWNDCLASS</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">style</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">inst</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mb_icon</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mb_cursor</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mb_bg</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mb_menu</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">cls</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-number">72</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-98"></span><span class="hs-pragma">{-# LINE 98 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-98"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-identifier">style</span><span>
</span><span id="line-99"></span><span class="hs-pragma">{-# LINE 99 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-99"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-identifier">genericWndProc_p</span><span>
</span><span id="line-100"></span><span class="hs-pragma">{-# LINE 100 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-100"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">INT</span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span class="hs-pragma">{-# LINE 101 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-101"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">20</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">INT</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-pragma">{-# LINE 102 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-102"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">24</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-identifier">inst</span><span>
</span><span id="line-103"></span><span class="hs-pragma">{-# LINE 103 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-103"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">32</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_icon</span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="hs-pragma">{-# LINE 104 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">40</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_cursor</span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span class="hs-pragma">{-# LINE 105 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-105"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">48</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_bg</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span class="hs-pragma">{-# LINE 106 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-106"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">56</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_menu</span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span class="hs-pragma">{-# LINE 107 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">64</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-identifier">cls</span><span>
</span><span id="line-108"></span><span class="hs-pragma">{-# LINE 108 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-108"></span><span>  </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">p</span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;WndProc.h &amp;genericWndProc&quot;</span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-identifier">genericWndProc_p</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">WindowClosure</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-pragma">{-# CFILES cbits/WndProc.c #-}</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-identifier">registerClass</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WNDCLASS</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">ATOM</span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span class="hs-identifier">registerClass</span><span> </span><span class="hs-identifier">cls</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-117"></span><span>  </span><span class="hs-identifier">withWNDCLASS</span><span> </span><span class="hs-identifier">cls</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-identifier">liftM</span><span> </span><span class="hs-identifier">numToMaybe</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_RegisterClass</span><span> </span><span class="hs-identifier">p</span><span>
</span><span id="line-119"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h RegisterClassW&quot;</span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-identifier">c_RegisterClass</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">WNDCLASS</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ATOM</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h UnregisterClassW&quot;</span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-identifier">unregisterClass</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassName</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HINSTANCE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- Window Style</span><span>
</span><span id="line-127"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">WindowStyle</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span class="hs-identifier">wS_OVERLAPPED</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-132"></span><span class="hs-identifier">wS_OVERLAPPED</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-133"></span><span class="hs-identifier">wS_POPUP</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-134"></span><span class="hs-identifier">wS_POPUP</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2147483648</span><span>
</span><span id="line-135"></span><span class="hs-identifier">wS_CHILD</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-136"></span><span class="hs-identifier">wS_CHILD</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1073741824</span><span>
</span><span id="line-137"></span><span class="hs-identifier">wS_CLIPSIBLINGS</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-138"></span><span class="hs-identifier">wS_CLIPSIBLINGS</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">67108864</span><span>
</span><span id="line-139"></span><span class="hs-identifier">wS_CLIPCHILDREN</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-140"></span><span class="hs-identifier">wS_CLIPCHILDREN</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">33554432</span><span>
</span><span id="line-141"></span><span class="hs-identifier">wS_VISIBLE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-142"></span><span class="hs-identifier">wS_VISIBLE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">268435456</span><span>
</span><span id="line-143"></span><span class="hs-identifier">wS_DISABLED</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-144"></span><span class="hs-identifier">wS_DISABLED</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">134217728</span><span>
</span><span id="line-145"></span><span class="hs-identifier">wS_MINIMIZE</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-146"></span><span class="hs-identifier">wS_MINIMIZE</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">536870912</span><span>
</span><span id="line-147"></span><span class="hs-identifier">wS_MAXIMIZE</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-148"></span><span class="hs-identifier">wS_MAXIMIZE</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16777216</span><span>
</span><span id="line-149"></span><span class="hs-identifier">wS_CAPTION</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-150"></span><span class="hs-identifier">wS_CAPTION</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">12582912</span><span>
</span><span id="line-151"></span><span class="hs-identifier">wS_BORDER</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-152"></span><span class="hs-identifier">wS_BORDER</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8388608</span><span>
</span><span id="line-153"></span><span class="hs-identifier">wS_DLGFRAME</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-154"></span><span class="hs-identifier">wS_DLGFRAME</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4194304</span><span>
</span><span id="line-155"></span><span class="hs-identifier">wS_VSCROLL</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-156"></span><span class="hs-identifier">wS_VSCROLL</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2097152</span><span>
</span><span id="line-157"></span><span class="hs-identifier">wS_HSCROLL</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-158"></span><span class="hs-identifier">wS_HSCROLL</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1048576</span><span>
</span><span id="line-159"></span><span class="hs-identifier">wS_SYSMENU</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-160"></span><span class="hs-identifier">wS_SYSMENU</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">524288</span><span>
</span><span id="line-161"></span><span class="hs-identifier">wS_THICKFRAME</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-162"></span><span class="hs-identifier">wS_THICKFRAME</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">262144</span><span>
</span><span id="line-163"></span><span class="hs-identifier">wS_MINIMIZEBOX</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-164"></span><span class="hs-identifier">wS_MINIMIZEBOX</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">131072</span><span>
</span><span id="line-165"></span><span class="hs-identifier">wS_MAXIMIZEBOX</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-166"></span><span class="hs-identifier">wS_MAXIMIZEBOX</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">65536</span><span>
</span><span id="line-167"></span><span class="hs-identifier">wS_GROUP</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-168"></span><span class="hs-identifier">wS_GROUP</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">131072</span><span>
</span><span id="line-169"></span><span class="hs-identifier">wS_TABSTOP</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-170"></span><span class="hs-identifier">wS_TABSTOP</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">65536</span><span>
</span><span id="line-171"></span><span class="hs-identifier">wS_OVERLAPPEDWINDOW</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-172"></span><span class="hs-identifier">wS_OVERLAPPEDWINDOW</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">13565952</span><span>
</span><span id="line-173"></span><span class="hs-identifier">wS_POPUPWINDOW</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-174"></span><span class="hs-identifier">wS_POPUPWINDOW</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2156396544</span><span>
</span><span id="line-175"></span><span class="hs-identifier">wS_CHILDWINDOW</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-176"></span><span class="hs-identifier">wS_CHILDWINDOW</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1073741824</span><span>
</span><span id="line-177"></span><span class="hs-identifier">wS_TILED</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-178"></span><span class="hs-identifier">wS_TILED</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-179"></span><span class="hs-identifier">wS_ICONIC</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-180"></span><span class="hs-identifier">wS_ICONIC</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">536870912</span><span>
</span><span id="line-181"></span><span class="hs-identifier">wS_SIZEBOX</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-182"></span><span class="hs-identifier">wS_SIZEBOX</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">262144</span><span>
</span><span id="line-183"></span><span class="hs-identifier">wS_TILEDWINDOW</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-184"></span><span class="hs-identifier">wS_TILEDWINDOW</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">13565952</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span class="hs-pragma">{-# LINE 160 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span class="hs-identifier">wS_EX_DLGMODALFRAME</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-164"></span><span class="hs-identifier">wS_EX_DLGMODALFRAME</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-165"></span><span class="hs-identifier">wS_EX_NOPARENTNOTIFY</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-166"></span><span class="hs-identifier">wS_EX_NOPARENTNOTIFY</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-167"></span><span class="hs-identifier">wS_EX_TOPMOST</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-168"></span><span class="hs-identifier">wS_EX_TOPMOST</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-169"></span><span class="hs-identifier">wS_EX_ACCEPTFILES</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-170"></span><span class="hs-identifier">wS_EX_ACCEPTFILES</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16</span><span>
</span><span id="line-171"></span><span class="hs-identifier">wS_EX_TRANSPARENT</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-172"></span><span class="hs-identifier">wS_EX_TRANSPARENT</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-173"></span><span class="hs-identifier">wS_EX_MDICHILD</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-174"></span><span class="hs-identifier">wS_EX_MDICHILD</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">64</span><span>
</span><span id="line-175"></span><span class="hs-identifier">wS_EX_TOOLWINDOW</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-176"></span><span class="hs-identifier">wS_EX_TOOLWINDOW</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-177"></span><span class="hs-identifier">wS_EX_WINDOWEDGE</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-178"></span><span class="hs-identifier">wS_EX_WINDOWEDGE</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">256</span><span>
</span><span id="line-179"></span><span class="hs-identifier">wS_EX_CLIENTEDGE</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-180"></span><span class="hs-identifier">wS_EX_CLIENTEDGE</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-181"></span><span class="hs-identifier">wS_EX_CONTEXTHELP</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-182"></span><span class="hs-identifier">wS_EX_CONTEXTHELP</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1024</span><span>
</span><span id="line-183"></span><span class="hs-identifier">wS_EX_RIGHT</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-184"></span><span class="hs-identifier">wS_EX_RIGHT</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4096</span><span>
</span><span id="line-185"></span><span class="hs-identifier">wS_EX_LEFT</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-186"></span><span class="hs-identifier">wS_EX_LEFT</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-187"></span><span class="hs-identifier">wS_EX_RTLREADING</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-188"></span><span class="hs-identifier">wS_EX_RTLREADING</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8192</span><span>
</span><span id="line-189"></span><span class="hs-identifier">wS_EX_LTRREADING</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-190"></span><span class="hs-identifier">wS_EX_LTRREADING</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-191"></span><span class="hs-identifier">wS_EX_LEFTSCROLLBAR</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-192"></span><span class="hs-identifier">wS_EX_LEFTSCROLLBAR</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16384</span><span>
</span><span id="line-193"></span><span class="hs-identifier">wS_EX_RIGHTSCROLLBAR</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-194"></span><span class="hs-identifier">wS_EX_RIGHTSCROLLBAR</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-195"></span><span class="hs-identifier">wS_EX_CONTROLPARENT</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-196"></span><span class="hs-identifier">wS_EX_CONTROLPARENT</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">65536</span><span>
</span><span id="line-197"></span><span class="hs-identifier">wS_EX_STATICEDGE</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-198"></span><span class="hs-identifier">wS_EX_STATICEDGE</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">131072</span><span>
</span><span id="line-199"></span><span class="hs-identifier">wS_EX_APPWINDOW</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-200"></span><span class="hs-identifier">wS_EX_APPWINDOW</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">262144</span><span>
</span><span id="line-201"></span><span class="hs-identifier">wS_EX_OVERLAPPEDWINDOW</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-202"></span><span class="hs-identifier">wS_EX_OVERLAPPEDWINDOW</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">768</span><span>
</span><span id="line-203"></span><span class="hs-identifier">wS_EX_PALETTEWINDOW</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span>
</span><span id="line-204"></span><span class="hs-identifier">wS_EX_PALETTEWINDOW</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">392</span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span class="hs-pragma">{-# LINE 186 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span class="hs-identifier">cW_USEDEFAULT</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- See Note [Overflow checking and fromIntegral] in Graphics/Win32/GDI/HDC.hs</span><span>
</span><span id="line-190"></span><span class="hs-comment">-- Weird way to essentially get a value with the top bit set. But GHC 7.8.4 was</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- rejecting all other sane attempts.</span><span>
</span><span id="line-192"></span><span class="hs-identifier">cW_USEDEFAULT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">val</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">negate</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">2147483648</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Integer</span><span>
</span><span id="line-193"></span><span class="hs-pragma">{-# LINE 193 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-193"></span><span>                </span><span class="hs-keyword">in</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">val</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int32</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MbPos</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-200"></span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromMaybe</span><span> </span><span class="hs-identifier">cW_USEDEFAULT</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">WindowClosure</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LRESULT</span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;wrapper&quot;</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-identifier">mkWindowClosure</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowClosure</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">WindowClosure</span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="hs-comment">-- | The standard C wndproc for every window class registered by</span><span>
</span><span id="line-208"></span><span class="hs-comment">-- 'registerClass' is a C function pointer provided with this library. It in</span><span>
</span><span id="line-209"></span><span class="hs-comment">-- turn delegates to a Haskell function pointer stored in 'gWLP_USERDATA'.</span><span>
</span><span id="line-210"></span><span class="hs-comment">-- This action creates that function pointer. All Haskell function pointers</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- must be freed in order to allow the objects they close over to be garbage</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- collected. Consequently, if you are replacing a window closure previously</span><span>
</span><span id="line-213"></span><span class="hs-comment">-- set via this method or indirectly with 'createWindow' or 'createWindowEx'</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- you must free it. This action returns a function pointer to the old window</span><span>
</span><span id="line-215"></span><span class="hs-comment">-- closure for you to free. The current window closure is freed automatically</span><span>
</span><span id="line-216"></span><span class="hs-comment">-- by 'defWindowProc' when it receives 'wM_NCDESTROY'.</span><span>
</span><span id="line-217"></span><span class="hs-identifier">setWindowClosure</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowClosure</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">WindowClosure</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span class="hs-identifier">setWindowClosure</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">closure</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-219"></span><span>  </span><span class="hs-identifier">fp</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">mkWindowClosure</span><span> </span><span class="hs-identifier">closure</span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-identifier">fpOld</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_SetWindowLongPtr</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">21</span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span class="hs-pragma">{-# LINE 221 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-221"></span><span>                              </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castFunPtrToPtr</span><span> </span><span class="hs-identifier">fp</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">fpOld</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">nullPtr</span><span> </span><span>
</span><span id="line-223"></span><span>     </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">Nothing</span><span>
</span><span id="line-224"></span><span>     </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Just</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">castPtrToFunPtr</span><span> </span><span class="hs-identifier">fpOld</span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span class="hs-comment">{- Note [SetWindowLongPtrW]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Windows.h defines SetWindowLongPtrW as SetWindowLongW for 32-bit platforms
(i386_HOST_ARCH for our mingw32 environment). Unfortunately since the foreign
import name is given inside of a string, the macro will not be expanded.

Until a better solution is presented each version is provided explicitly here.

-}</span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span class="hs-pragma">{-# LINE 239 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-239"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetWindowLongPtrW&quot;</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="hs-pragma">{-# LINE 243 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-243"></span><span>  </span><span class="hs-identifier">c_SetWindowLongPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">LONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">LONG</span><span class="hs-special">)</span><span>
</span><span id="line-244"></span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span class="hs-pragma">{-# LINE 248 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-248"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetWindowLongPtrW&quot;</span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span class="hs-pragma">{-# LINE 252 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-252"></span><span>  </span><span class="hs-identifier">c_GetWindowLongPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LONG_PTR</span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span class="hs-comment">-- | Creates a window with a default extended window style. If you create many</span><span>
</span><span id="line-256"></span><span class="hs-comment">-- windows over the life of your program, WindowClosure may leak memory. Be</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- sure to delegate to 'defWindowProc' for 'wM_NCDESTROY' and see</span><span>
</span><span id="line-258"></span><span class="hs-comment">-- 'defWindowProc' and 'setWindowClosure' for details.</span><span>
</span><span id="line-259"></span><span class="hs-identifier">createWindow</span><span>
</span><span id="line-260"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClassName</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-261"></span><span>     </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-262"></span><span>     </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HMENU</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HINSTANCE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowClosure</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-263"></span><span>     </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-264"></span><span class="hs-identifier">createWindow</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">createWindowEx</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-265"></span><span class="hs-comment">-- apparently CreateWindowA/W are just macros for CreateWindowExA/W</span><span>
</span><span id="line-266"></span><span>
</span><span id="line-267"></span><span class="hs-comment">-- | Creates a window and allows your to specify the  extended window style. If</span><span>
</span><span id="line-268"></span><span class="hs-comment">-- you create many windows over the life of your program, WindowClosure may</span><span>
</span><span id="line-269"></span><span class="hs-comment">-- leak memory. Be sure to delegate to 'defWindowProc' for 'wM_NCDESTROY' and see</span><span>
</span><span id="line-270"></span><span class="hs-comment">-- 'defWindowProc' and 'setWindowClosure' for details.</span><span>
</span><span id="line-271"></span><span class="hs-identifier">createWindowEx</span><span>
</span><span id="line-272"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ClassName</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-273"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-274"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HMENU</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HINSTANCE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowClosure</span><span>
</span><span id="line-275"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-276"></span><span class="hs-identifier">createWindowEx</span><span> </span><span class="hs-identifier">estyle</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-identifier">wstyle</span><span> </span><span class="hs-identifier">mb_x</span><span> </span><span class="hs-identifier">mb_y</span><span> </span><span class="hs-identifier">mb_w</span><span> </span><span class="hs-identifier">mb_h</span><span> </span><span class="hs-identifier">mb_parent</span><span> </span><span class="hs-identifier">mb_menu</span><span> </span><span class="hs-identifier">inst</span><span> </span><span class="hs-identifier">closure</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-277"></span><span>  </span><span class="hs-comment">-- Freeing the title/window name has been reported</span><span>
</span><span id="line-278"></span><span>  </span><span class="hs-comment">-- to cause a crash, so let's not do it.</span><span>
</span><span id="line-279"></span><span>  </span><span class="hs-comment">-- withTString wname $ \ c_wname -&gt; do</span><span>
</span><span id="line-280"></span><span>  </span><span class="hs-identifier">c_wname</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">newTString</span><span> </span><span class="hs-identifier">wname</span><span>
</span><span id="line-281"></span><span>  </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;CreateWindowEx&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-282"></span><span>    </span><span class="hs-identifier">c_CreateWindowEx</span><span> </span><span class="hs-identifier">estyle</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-identifier">c_wname</span><span> </span><span class="hs-identifier">wstyle</span><span>
</span><span id="line-283"></span><span>      </span><span class="hs-special">(</span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-identifier">mb_x</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-identifier">mb_y</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-identifier">mb_w</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePos</span><span> </span><span class="hs-identifier">mb_h</span><span class="hs-special">)</span><span>
</span><span id="line-284"></span><span>      </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_parent</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_menu</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">inst</span><span> </span><span class="hs-identifier">nullPtr</span><span>
</span><span id="line-285"></span><span>  </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">setWindowClosure</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">closure</span><span>
</span><span id="line-286"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-287"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h CreateWindowExW&quot;</span><span>
</span><span id="line-288"></span><span>  </span><span class="hs-identifier">c_CreateWindowEx</span><span>
</span><span id="line-289"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ClassName</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span>
</span><span id="line-290"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Pos</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Pos</span><span>
</span><span id="line-291"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HMENU</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HINSTANCE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPVOID</span><span>
</span><span id="line-292"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-293"></span><span>
</span><span id="line-294"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-295"></span><span>
</span><span id="line-296"></span><span class="hs-comment">-- | Delegates to the Win32 default window procedure. If you are using a</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- window created by 'createWindow', 'createWindowEx' or on which you have</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- called 'setWindowClosure', please note that the window will leak memory once</span><span>
</span><span id="line-299"></span><span class="hs-comment">-- it is destroyed unless you call 'freeWindowProc' when it receives</span><span>
</span><span id="line-300"></span><span class="hs-comment">-- 'wM_NCDESTROY'. If you wish to do this, instead of using this function</span><span>
</span><span id="line-301"></span><span class="hs-comment">-- directly, you can delegate to 'defWindowProcSafe' which will handle it for</span><span>
</span><span id="line-302"></span><span class="hs-comment">-- you. As an alternative, you can manually retrieve the window closure</span><span>
</span><span id="line-303"></span><span class="hs-comment">-- function pointer and free it after the window has been destroyed. Check the</span><span>
</span><span id="line-304"></span><span class="hs-comment">-- implementation of 'freeWindowProc' for a guide.</span><span>
</span><span id="line-305"></span><span class="hs-identifier">defWindowProc</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LRESULT</span><span>
</span><span id="line-306"></span><span class="hs-identifier">defWindowProc</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-307"></span><span>  </span><span class="hs-identifier">c_DefWindowProc</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">l</span><span>
</span><span id="line-308"></span><span>
</span><span id="line-309"></span><span class="hs-comment">-- | Delegates to the standard default window procedure, but if it receives the</span><span>
</span><span id="line-310"></span><span class="hs-comment">-- 'wM_NCDESTROY' message it first frees the window closure to allow the</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- closure and any objects it closes over to be garbage collected. 'wM_NCDESTROY' is</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- the last message a window receives prior to being deleted.</span><span>
</span><span id="line-313"></span><span class="hs-identifier">defWindowProcSafe</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LRESULT</span><span>
</span><span id="line-314"></span><span class="hs-identifier">defWindowProcSafe</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-315"></span><span>  </span><span class="hs-identifier">when</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msg</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">wM_NCDESTROY</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">freeWindowProc</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>  </span><span class="hs-identifier">defWindowProc</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">l</span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h DefWindowProcW&quot;</span><span>
</span><span id="line-319"></span><span>  </span><span class="hs-identifier">c_DefWindowProc</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LRESULT</span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span class="hs-comment">-- | Frees a function pointer to the window closure which has been set</span><span>
</span><span id="line-322"></span><span class="hs-comment">-- directly by 'setWindowClosure' or indirectly by 'createWindowEx'. You</span><span>
</span><span id="line-323"></span><span class="hs-comment">-- should call this function in your window closure's 'wM_NCDESTROY' case</span><span>
</span><span id="line-324"></span><span class="hs-comment">-- unless you delegate that case to 'defWindowProc' (e.g. as part of the</span><span>
</span><span id="line-325"></span><span class="hs-comment">-- default).</span><span>
</span><span id="line-326"></span><span class="hs-identifier">freeWindowProc</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-327"></span><span class="hs-identifier">freeWindowProc</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-328"></span><span>   </span><span class="hs-identifier">fp</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_GetWindowLongPtr</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-number">21</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span class="hs-pragma">{-# LINE 329 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-329"></span><span>   </span><span class="hs-identifier">unless</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fp</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span>
</span><span id="line-330"></span><span>      </span><span class="hs-identifier">freeHaskellFunPtr</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">castPtrToFunPtr</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">intPtrToPtr</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">fp</span><span>
</span><span id="line-331"></span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span class="hs-identifier">getClientRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">RECT</span><span>
</span><span id="line-336"></span><span class="hs-identifier">getClientRect</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-337"></span><span>  </span><span class="hs-identifier">allocaRECT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-338"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetClientRect&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetClientRect</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-339"></span><span>  </span><span class="hs-identifier">peekRECT</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-340"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetClientRect&quot;</span><span>
</span><span id="line-341"></span><span>  </span><span class="hs-identifier">c_GetClientRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-342"></span><span>
</span><span id="line-343"></span><span class="hs-identifier">getWindowRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">RECT</span><span>
</span><span id="line-344"></span><span class="hs-identifier">getWindowRect</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-identifier">allocaRECT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetWindowRect&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetWindowRect</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-347"></span><span>  </span><span class="hs-identifier">peekRECT</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-348"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetWindowRect&quot;</span><span>
</span><span id="line-349"></span><span>  </span><span class="hs-identifier">c_GetWindowRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span class="hs-comment">-- Should it be Maybe RECT instead?</span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span class="hs-identifier">invalidateRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">LPRECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-354"></span><span class="hs-identifier">invalidateRect</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_mb_rect</span><span> </span><span class="hs-identifier">erase</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-355"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;InvalidateRect&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-356"></span><span>    </span><span class="hs-identifier">c_InvalidateRect</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">wnd</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">p_mb_rect</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">erase</span><span>
</span><span id="line-357"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h InvalidateRect&quot;</span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-identifier">c_InvalidateRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPRECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-identifier">screenToClient</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">POINT</span><span>
</span><span id="line-361"></span><span class="hs-identifier">screenToClient</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-362"></span><span>  </span><span class="hs-identifier">withPOINT</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-363"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;ScreenToClient&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_ScreenToClient</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-364"></span><span>  </span><span class="hs-identifier">peekPOINT</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-365"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ScreenToClient&quot;</span><span>
</span><span id="line-366"></span><span>  </span><span class="hs-identifier">c_ScreenToClient</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="hs-identifier">clientToScreen</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">POINT</span><span>
</span><span id="line-369"></span><span class="hs-identifier">clientToScreen</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-370"></span><span>  </span><span class="hs-identifier">withPOINT</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-371"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;ClientToScreen&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_ClientToScreen</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-372"></span><span>  </span><span class="hs-identifier">peekPOINT</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-373"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ClientToScreen&quot;</span><span>
</span><span id="line-374"></span><span>  </span><span class="hs-identifier">c_ClientToScreen</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-375"></span><span>
</span><span id="line-376"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-377"></span><span class="hs-comment">-- Setting window text/label</span><span>
</span><span id="line-378"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-379"></span><span class="hs-comment">-- For setting the title bar text.  But inconvenient to make the LPCTSTR</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span class="hs-identifier">setWindowText</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span class="hs-identifier">setWindowText</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-383"></span><span>  </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_text</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-384"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;SetWindowText&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetWindowText</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">c_text</span><span>
</span><span id="line-385"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h SetWindowTextW&quot;</span><span>
</span><span id="line-386"></span><span>  </span><span class="hs-identifier">c_SetWindowText</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- Getting window text/label</span><span>
</span><span id="line-390"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-391"></span><span class="hs-comment">-- For getting the title bar text. </span><span>
</span><span id="line-392"></span><span class="hs-comment">-- If the window has no title bar or text, if the title bar is empty,</span><span>
</span><span id="line-393"></span><span class="hs-comment">-- or if the window or control handle is invalid, the return value is zero.</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- If invalid handle throws exception.</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- If size &lt;= 0 throws exception.</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span class="hs-identifier">getWindowText</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-398"></span><span class="hs-identifier">getWindowText</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">size</span><span> </span><span>
</span><span id="line-399"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">size</span><span> </span><span class="hs-operator">&lt;=</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">errorWin</span><span> </span><span class="hs-string">&quot;GetWindowTextW&quot;</span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-401"></span><span>      </span><span class="hs-identifier">allocaArray</span><span> </span><span class="hs-identifier">size</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-402"></span><span>      </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_GetWindowText</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_buf</span><span> </span><span class="hs-identifier">size</span><span>
</span><span id="line-403"></span><span>      </span><span class="hs-identifier">failUnlessSuccess</span><span> </span><span class="hs-string">&quot;GetWindowTextW&quot;</span><span> </span><span class="hs-identifier">getLastError</span><span>
</span><span id="line-404"></span><span>      </span><span class="hs-identifier">peekTString</span><span> </span><span class="hs-identifier">p_buf</span><span>
</span><span id="line-405"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h GetWindowTextW&quot;</span><span>
</span><span id="line-406"></span><span>  </span><span class="hs-identifier">c_GetWindowText</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-409"></span><span class="hs-comment">-- Getting window text length</span><span>
</span><span id="line-410"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-411"></span><span class="hs-comment">-- For getting the title bar text length. </span><span>
</span><span id="line-412"></span><span class="hs-comment">-- If the window has no text, the return value is zero.</span><span>
</span><span id="line-413"></span><span class="hs-comment">-- If invalid handle throws exception.</span><span>
</span><span id="line-414"></span><span>  </span><span>
</span><span id="line-415"></span><span class="hs-identifier">getWindowTextLength</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-416"></span><span class="hs-identifier">getWindowTextLength</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-417"></span><span>  </span><span class="hs-identifier">size'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_GetWindowTextLength</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-418"></span><span>  </span><span class="hs-identifier">failUnlessSuccess</span><span> </span><span class="hs-string">&quot;GetWindowTextLengthW&quot;</span><span> </span><span class="hs-identifier">getLastError</span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">size'</span><span>
</span><span id="line-420"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h GetWindowTextLengthW&quot;</span><span>
</span><span id="line-421"></span><span>  </span><span class="hs-identifier">c_GetWindowTextLength</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-422"></span><span>  </span><span>
</span><span id="line-423"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- Paint struct</span><span>
</span><span id="line-425"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">PAINTSTRUCT</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-428"></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">HDC</span><span>   </span><span class="hs-comment">-- hdc</span><span>
</span><span id="line-429"></span><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Bool</span><span>  </span><span class="hs-comment">-- fErase</span><span>
</span><span id="line-430"></span><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">RECT</span><span>  </span><span class="hs-comment">-- rcPaint</span><span>
</span><span id="line-431"></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">LPPAINTSTRUCT</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Addr</span><span>
</span><span id="line-434"></span><span>
</span><span id="line-435"></span><span class="hs-identifier">sizeofPAINTSTRUCT</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-436"></span><span class="hs-identifier">sizeofPAINTSTRUCT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-number">72</span><span class="hs-special">)</span><span>
</span><span id="line-437"></span><span class="hs-pragma">{-# LINE 437 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-437"></span><span>
</span><span id="line-438"></span><span class="hs-identifier">allocaPAINTSTRUCT</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">LPPAINTSTRUCT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-439"></span><span class="hs-identifier">allocaPAINTSTRUCT</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-number">72</span><span class="hs-special">)</span><span>
</span><span id="line-440"></span><span class="hs-pragma">{-# LINE 440 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-identifier">beginPaint</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPPAINTSTRUCT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-442"></span><span class="hs-identifier">beginPaint</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">paint</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-443"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;BeginPaint&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_BeginPaint</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">paint</span><span>
</span><span id="line-444"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h BeginPaint&quot;</span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-identifier">c_BeginPaint</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPPAINTSTRUCT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-446"></span><span>
</span><span id="line-447"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h EndPaint&quot;</span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-identifier">endPaint</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPPAINTSTRUCT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-449"></span><span class="hs-comment">-- Apparently always succeeds (return non-zero)</span><span>
</span><span id="line-450"></span><span>
</span><span id="line-451"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-452"></span><span class="hs-comment">-- ShowWindow</span><span>
</span><span id="line-453"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-456"></span><span>
</span><span id="line-457"></span><span class="hs-identifier">sW_HIDE</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-458"></span><span class="hs-identifier">sW_HIDE</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">0</span><span>
</span><span id="line-459"></span><span class="hs-identifier">sW_SHOWNORMAL</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-460"></span><span class="hs-identifier">sW_SHOWNORMAL</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-461"></span><span class="hs-identifier">sW_SHOWMINIMIZED</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-462"></span><span class="hs-identifier">sW_SHOWMINIMIZED</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-463"></span><span class="hs-identifier">sW_SHOWMAXIMIZED</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-464"></span><span class="hs-identifier">sW_SHOWMAXIMIZED</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">3</span><span>
</span><span id="line-465"></span><span class="hs-identifier">sW_MAXIMIZE</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-466"></span><span class="hs-identifier">sW_MAXIMIZE</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">3</span><span>
</span><span id="line-467"></span><span class="hs-identifier">sW_SHOWNOACTIVATE</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-468"></span><span class="hs-identifier">sW_SHOWNOACTIVATE</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-469"></span><span class="hs-identifier">sW_SHOW</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-470"></span><span class="hs-identifier">sW_SHOW</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">5</span><span>
</span><span id="line-471"></span><span class="hs-identifier">sW_MINIMIZE</span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-472"></span><span class="hs-identifier">sW_MINIMIZE</span><span>           </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">6</span><span>
</span><span id="line-473"></span><span class="hs-identifier">sW_SHOWMINNOACTIVE</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-474"></span><span class="hs-identifier">sW_SHOWMINNOACTIVE</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">7</span><span>
</span><span id="line-475"></span><span class="hs-identifier">sW_SHOWNA</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-476"></span><span class="hs-identifier">sW_SHOWNA</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-477"></span><span class="hs-identifier">sW_RESTORE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>
</span><span id="line-478"></span><span class="hs-identifier">sW_RESTORE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">9</span><span>
</span><span id="line-479"></span><span>
</span><span id="line-480"></span><span class="hs-pragma">{-# LINE 470 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h ShowWindow&quot;</span><span>
</span><span id="line-472"></span><span>  </span><span class="hs-identifier">showWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ShowWindowControl</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-473"></span><span>
</span><span id="line-474"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h IsWindowVisible&quot;</span><span>
</span><span id="line-475"></span><span>  </span><span class="hs-identifier">isWindowVisible</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-476"></span><span>
</span><span id="line-477"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-478"></span><span class="hs-comment">-- Misc</span><span>
</span><span id="line-479"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-480"></span><span>
</span><span id="line-481"></span><span class="hs-identifier">adjustWindowRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">RECT</span><span>
</span><span id="line-482"></span><span class="hs-identifier">adjustWindowRect</span><span> </span><span class="hs-identifier">rect</span><span> </span><span class="hs-identifier">style</span><span> </span><span class="hs-identifier">menu</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-483"></span><span>  </span><span class="hs-identifier">withRECT</span><span> </span><span class="hs-identifier">rect</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-484"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;AdjustWindowRect&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_AdjustWindowRect</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-identifier">style</span><span> </span><span class="hs-identifier">menu</span><span>
</span><span id="line-485"></span><span>  </span><span class="hs-identifier">peekRECT</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-486"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h AdjustWindowRect&quot;</span><span>
</span><span id="line-487"></span><span>  </span><span class="hs-identifier">c_AdjustWindowRect</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-488"></span><span>
</span><span id="line-489"></span><span class="hs-identifier">adjustWindowRectEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">RECT</span><span>
</span><span id="line-490"></span><span class="hs-identifier">adjustWindowRectEx</span><span> </span><span class="hs-identifier">rect</span><span> </span><span class="hs-identifier">style</span><span> </span><span class="hs-identifier">menu</span><span> </span><span class="hs-identifier">exstyle</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-491"></span><span>  </span><span class="hs-identifier">withRECT</span><span> </span><span class="hs-identifier">rect</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-492"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;AdjustWindowRectEx&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-493"></span><span>    </span><span class="hs-identifier">c_AdjustWindowRectEx</span><span> </span><span class="hs-identifier">p_rect</span><span> </span><span class="hs-identifier">style</span><span> </span><span class="hs-identifier">menu</span><span> </span><span class="hs-identifier">exstyle</span><span>
</span><span id="line-494"></span><span>  </span><span class="hs-identifier">peekRECT</span><span> </span><span class="hs-identifier">p_rect</span><span>
</span><span id="line-495"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h AdjustWindowRectEx&quot;</span><span>
</span><span id="line-496"></span><span>  </span><span class="hs-identifier">c_AdjustWindowRectEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">RECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyle</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowStyleEx</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-497"></span><span>
</span><span id="line-498"></span><span class="hs-comment">-- Win2K and later:</span><span>
</span><span id="line-499"></span><span class="hs-comment">-- %fun AllowSetForegroundWindow :: DWORD -&gt; IO ()</span><span>
</span><span id="line-500"></span><span>
</span><span id="line-501"></span><span class="hs-comment">-- %</span><span>
</span><span id="line-502"></span><span class="hs-comment">-- %dis animateWindowType x = dWORD x</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- type AnimateWindowType   = DWORD</span><span>
</span><span id="line-504"></span><span>
</span><span id="line-505"></span><span class="hs-comment">-- %const AnimateWindowType</span><span>
</span><span id="line-506"></span><span class="hs-comment">--        [ AW_SLIDE</span><span>
</span><span id="line-507"></span><span class="hs-comment">--        , AW_ACTIVATE</span><span>
</span><span id="line-508"></span><span class="hs-comment">--        , AW_BLEND</span><span>
</span><span id="line-509"></span><span class="hs-comment">--        , AW_HIDE</span><span>
</span><span id="line-510"></span><span class="hs-comment">--        , AW_CENTER</span><span>
</span><span id="line-511"></span><span class="hs-comment">--        , AW_HOR_POSITIVE</span><span>
</span><span id="line-512"></span><span class="hs-comment">--        , AW_HOR_NEGATIVE</span><span>
</span><span id="line-513"></span><span class="hs-comment">--        , AW_VER_POSITIVE</span><span>
</span><span id="line-514"></span><span class="hs-comment">--        , AW_VER_NEGATIVE</span><span>
</span><span id="line-515"></span><span class="hs-comment">--        ]</span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span class="hs-comment">-- Win98 or Win2K:</span><span>
</span><span id="line-518"></span><span class="hs-comment">-- %fun AnimateWindow :: HWND -&gt; DWORD -&gt; AnimateWindowType -&gt; IO ()</span><span>
</span><span id="line-519"></span><span class="hs-comment">-- %code BOOL success = AnimateWindow(arg1,arg2,arg3)</span><span>
</span><span id="line-520"></span><span class="hs-comment">-- %fail { !success } { ErrorWin(&quot;AnimateWindow&quot;) }</span><span>
</span><span id="line-521"></span><span>
</span><span id="line-522"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h AnyPopup&quot;</span><span>
</span><span id="line-523"></span><span>  </span><span class="hs-identifier">anyPopup</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span class="hs-identifier">arrangeIconicWindows</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-526"></span><span class="hs-identifier">arrangeIconicWindows</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-527"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;ArrangeIconicWindows&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_ArrangeIconicWindows</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-528"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ArrangeIconicWindows&quot;</span><span>
</span><span id="line-529"></span><span>  </span><span class="hs-identifier">c_ArrangeIconicWindows</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="hs-identifier">beginDeferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDWP</span><span>
</span><span id="line-532"></span><span class="hs-identifier">beginDeferWindowPos</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;BeginDeferWindowPos&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_BeginDeferWindowPos</span><span> </span><span class="hs-identifier">n</span><span>
</span><span id="line-534"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h BeginDeferWindowPos&quot;</span><span>
</span><span id="line-535"></span><span>  </span><span class="hs-identifier">c_BeginDeferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDWP</span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span class="hs-identifier">bringWindowToTop</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-538"></span><span class="hs-identifier">bringWindowToTop</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-539"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;BringWindowToTop&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_BringWindowToTop</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-540"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h BringWindowToTop&quot;</span><span>
</span><span id="line-541"></span><span>  </span><span class="hs-identifier">c_BringWindowToTop</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-542"></span><span>
</span><span id="line-543"></span><span class="hs-comment">-- Can't pass structs with current FFI, so use a C wrapper (in Types)</span><span>
</span><span id="line-544"></span><span class="hs-identifier">childWindowFromPoint</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span class="hs-identifier">childWindowFromPoint</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-546"></span><span>  </span><span class="hs-identifier">withPOINT</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-547"></span><span>  </span><span class="hs-identifier">liftM</span><span> </span><span class="hs-identifier">ptrToMaybe</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">prim_ChildWindowFromPoint</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-548"></span><span>
</span><span id="line-549"></span><span class="hs-comment">-- Can't pass structs with current FFI, so use a C wrapper (in Types)</span><span>
</span><span id="line-550"></span><span class="hs-identifier">childWindowFromPointEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span class="hs-identifier">childWindowFromPointEx</span><span> </span><span class="hs-identifier">parent</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-552"></span><span>  </span><span class="hs-identifier">withPOINT</span><span> </span><span class="hs-identifier">pt</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-553"></span><span>  </span><span class="hs-identifier">liftM</span><span> </span><span class="hs-identifier">ptrToMaybe</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">prim_ChildWindowFromPointEx</span><span> </span><span class="hs-identifier">parent</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-identifier">flags</span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span class="hs-identifier">closeWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-556"></span><span class="hs-identifier">closeWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-557"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;CloseWindow&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_DestroyWindow</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-558"></span><span>
</span><span id="line-559"></span><span class="hs-identifier">deferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDWP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDWP</span><span>
</span><span id="line-560"></span><span class="hs-identifier">deferWindowPos</span><span> </span><span class="hs-identifier">wp</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">after</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-identifier">cx</span><span> </span><span class="hs-identifier">cy</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-561"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;DeferWindowPos&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_DeferWindowPos</span><span> </span><span class="hs-identifier">wp</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">after</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-identifier">cx</span><span> </span><span class="hs-identifier">cy</span><span> </span><span class="hs-identifier">flags</span><span>
</span><span id="line-562"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h DeferWindowPos&quot;</span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-identifier">c_DeferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDWP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDWP</span><span>
</span><span id="line-564"></span><span>
</span><span id="line-565"></span><span class="hs-identifier">destroyWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-566"></span><span class="hs-identifier">destroyWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-567"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;DestroyWindow&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_DestroyWindow</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-568"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h DestroyWindow&quot;</span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-identifier">c_DestroyWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-570"></span><span>
</span><span id="line-571"></span><span class="hs-identifier">endDeferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDWP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-572"></span><span class="hs-identifier">endDeferWindowPos</span><span> </span><span class="hs-identifier">pos</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-573"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;EndDeferWindowPos&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_EndDeferWindowPos</span><span> </span><span class="hs-identifier">pos</span><span>
</span><span id="line-574"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h EndDeferWindowPos&quot;</span><span>
</span><span id="line-575"></span><span>  </span><span class="hs-identifier">c_EndDeferWindowPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDWP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span class="hs-identifier">findWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-578"></span><span class="hs-identifier">findWindow</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-579"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_cname</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-580"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_wname</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-581"></span><span>  </span><span class="hs-identifier">liftM</span><span> </span><span class="hs-identifier">ptrToMaybe</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_FindWindow</span><span> </span><span class="hs-identifier">c_cname</span><span> </span><span class="hs-identifier">c_wname</span><span>
</span><span id="line-582"></span><span>
</span><span id="line-583"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">findWindowByName</span><span> </span><span class="hs-pragma">&quot;Use 'findWindow Nothing' instead.&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-584"></span><span class="hs-identifier">findWindowByName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-585"></span><span class="hs-identifier">findWindowByName</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">findWindow</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">wname</span><span>
</span><span id="line-586"></span><span>
</span><span id="line-587"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h FindWindowW&quot;</span><span>
</span><span id="line-588"></span><span>  </span><span class="hs-identifier">c_FindWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-589"></span><span>
</span><span id="line-590"></span><span class="hs-identifier">findWindowEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-591"></span><span class="hs-identifier">findWindowEx</span><span> </span><span class="hs-identifier">parent</span><span> </span><span class="hs-identifier">after</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">cname</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_cname</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-593"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">wname</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_wname</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-594"></span><span>  </span><span class="hs-identifier">liftM</span><span> </span><span class="hs-identifier">ptrToMaybe</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_FindWindowEx</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">parent</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">after</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">c_cname</span><span> </span><span class="hs-identifier">c_wname</span><span>
</span><span id="line-595"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h FindWindowExW&quot;</span><span>
</span><span id="line-596"></span><span>  </span><span class="hs-identifier">c_FindWindowEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-597"></span><span>
</span><span id="line-598"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h FlashWindow&quot;</span><span>
</span><span id="line-599"></span><span>  </span><span class="hs-identifier">flashWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-600"></span><span class="hs-comment">-- No error code</span><span>
</span><span id="line-601"></span><span>
</span><span id="line-602"></span><span class="hs-identifier">moveWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-603"></span><span class="hs-identifier">moveWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">repaint</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-604"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;MoveWindow&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_MoveWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">repaint</span><span>
</span><span id="line-605"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h MoveWindow&quot;</span><span>
</span><span id="line-606"></span><span>  </span><span class="hs-identifier">c_MoveWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-607"></span><span>
</span><span id="line-608"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetDesktopWindow&quot;</span><span>
</span><span id="line-609"></span><span>  </span><span class="hs-identifier">getDesktopWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-610"></span><span>
</span><span id="line-611"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetForegroundWindow&quot;</span><span>
</span><span id="line-612"></span><span>  </span><span class="hs-identifier">getForegroundWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-613"></span><span>  </span><span>
</span><span id="line-614"></span><span class="hs-identifier">getParent</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-615"></span><span class="hs-identifier">getParent</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-616"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetParent&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetParent</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-617"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetParent&quot;</span><span>
</span><span id="line-618"></span><span>  </span><span class="hs-identifier">c_GetParent</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-619"></span><span>
</span><span id="line-620"></span><span class="hs-identifier">getTopWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-621"></span><span class="hs-identifier">getTopWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-622"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetTopWindow&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetTopWindow</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-623"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetTopWindow&quot;</span><span>
</span><span id="line-624"></span><span>  </span><span class="hs-identifier">c_GetTopWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span>
</span><span id="line-627"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-628"></span><span>
</span><span id="line-629"></span><span class="hs-identifier">sWP_NOSIZE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-630"></span><span class="hs-identifier">sWP_NOSIZE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-631"></span><span class="hs-identifier">sWP_NOMOVE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-632"></span><span class="hs-identifier">sWP_NOMOVE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-633"></span><span class="hs-identifier">sWP_NOZORDER</span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-634"></span><span class="hs-identifier">sWP_NOZORDER</span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-635"></span><span class="hs-identifier">sWP_NOREDRAW</span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-636"></span><span class="hs-identifier">sWP_NOREDRAW</span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-637"></span><span class="hs-identifier">sWP_NOACTIVATE</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-638"></span><span class="hs-identifier">sWP_NOACTIVATE</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16</span><span>
</span><span id="line-639"></span><span class="hs-identifier">sWP_FRAMECHANGED</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-640"></span><span class="hs-identifier">sWP_FRAMECHANGED</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-641"></span><span class="hs-identifier">sWP_SHOWWINDOW</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-642"></span><span class="hs-identifier">sWP_SHOWWINDOW</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">64</span><span>
</span><span id="line-643"></span><span class="hs-identifier">sWP_HIDEWINDOW</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-644"></span><span class="hs-identifier">sWP_HIDEWINDOW</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-645"></span><span class="hs-identifier">sWP_NOCOPYBITS</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-646"></span><span class="hs-identifier">sWP_NOCOPYBITS</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">256</span><span>
</span><span id="line-647"></span><span class="hs-identifier">sWP_NOOWNERZORDER</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-648"></span><span class="hs-identifier">sWP_NOOWNERZORDER</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-649"></span><span class="hs-identifier">sWP_NOSENDCHANGING</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-650"></span><span class="hs-identifier">sWP_NOSENDCHANGING</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1024</span><span>
</span><span id="line-651"></span><span class="hs-identifier">sWP_DRAWFRAME</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-652"></span><span class="hs-identifier">sWP_DRAWFRAME</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-653"></span><span class="hs-identifier">sWP_NOREPOSITION</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetWindowPosFlags</span><span>
</span><span id="line-654"></span><span class="hs-identifier">sWP_NOREPOSITION</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span class="hs-pragma">{-# LINE 644 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-644"></span><span>
</span><span id="line-645"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-646"></span><span class="hs-comment">-- HDCs</span><span>
</span><span id="line-647"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-648"></span><span>
</span><span id="line-649"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-650"></span><span>
</span><span id="line-651"></span><span class="hs-identifier">dCX_WINDOW</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-652"></span><span class="hs-identifier">dCX_WINDOW</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-653"></span><span class="hs-identifier">dCX_CACHE</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-654"></span><span class="hs-identifier">dCX_CACHE</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-655"></span><span class="hs-identifier">dCX_CLIPCHILDREN</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-656"></span><span class="hs-identifier">dCX_CLIPCHILDREN</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-657"></span><span class="hs-identifier">dCX_CLIPSIBLINGS</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-658"></span><span class="hs-identifier">dCX_CLIPSIBLINGS</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16</span><span>
</span><span id="line-659"></span><span class="hs-identifier">dCX_PARENTCLIP</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-660"></span><span class="hs-identifier">dCX_PARENTCLIP</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-661"></span><span class="hs-identifier">dCX_EXCLUDERGN</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-662"></span><span class="hs-identifier">dCX_EXCLUDERGN</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">64</span><span>
</span><span id="line-663"></span><span class="hs-identifier">dCX_INTERSECTRGN</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-664"></span><span class="hs-identifier">dCX_INTERSECTRGN</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-665"></span><span class="hs-identifier">dCX_LOCKWINDOWUPDATE</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span>
</span><span id="line-666"></span><span class="hs-identifier">dCX_LOCKWINDOWUPDATE</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1024</span><span>
</span><span id="line-667"></span><span>
</span><span id="line-668"></span><span class="hs-pragma">{-# LINE 661 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-661"></span><span>
</span><span id="line-662"></span><span class="hs-comment">-- apparently mostly fails if you use invalid hwnds</span><span>
</span><span id="line-663"></span><span>
</span><span id="line-664"></span><span class="hs-identifier">getDCEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HRGN</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-665"></span><span class="hs-identifier">getDCEx</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">rgn</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-666"></span><span>  </span><span class="hs-identifier">withForeignPtr</span><span> </span><span class="hs-identifier">rgn</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_rgn</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-667"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetDCEx&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetDCEx</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">p_rgn</span><span> </span><span class="hs-identifier">flags</span><span>
</span><span id="line-668"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetDCEx&quot;</span><span>
</span><span id="line-669"></span><span>  </span><span class="hs-identifier">c_GetDCEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">PRGN</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">GetDCExFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span class="hs-identifier">getDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-672"></span><span class="hs-identifier">getDC</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-673"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetDC&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetDC</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span>
</span><span id="line-674"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetDC&quot;</span><span>
</span><span id="line-675"></span><span>  </span><span class="hs-identifier">c_GetDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-676"></span><span>
</span><span id="line-677"></span><span class="hs-identifier">getWindowDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-678"></span><span class="hs-identifier">getWindowDC</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-679"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetWindowDC&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetWindowDC</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span>
</span><span id="line-680"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetWindowDC&quot;</span><span>
</span><span id="line-681"></span><span>  </span><span class="hs-identifier">c_GetWindowDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HDC</span><span>
</span><span id="line-682"></span><span>
</span><span id="line-683"></span><span class="hs-identifier">releaseDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HDC</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-684"></span><span class="hs-identifier">releaseDC</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">dc</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-685"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;ReleaseDC&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_ReleaseDC</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">dc</span><span>
</span><span id="line-686"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ReleaseDC&quot;</span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-identifier">c_ReleaseDC</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HDC</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span class="hs-identifier">getDCOrgEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDC</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">POINT</span><span>
</span><span id="line-690"></span><span class="hs-identifier">getDCOrgEx</span><span> </span><span class="hs-identifier">dc</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-691"></span><span>  </span><span class="hs-identifier">allocaPOINT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-692"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetDCOrgEx&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetDCOrgEx</span><span> </span><span class="hs-identifier">dc</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-693"></span><span>  </span><span class="hs-identifier">peekPOINT</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-694"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetDCOrgEx&quot;</span><span>
</span><span id="line-695"></span><span>  </span><span class="hs-identifier">c_GetDCOrgEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HDC</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-696"></span><span>
</span><span id="line-697"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- Caret</span><span>
</span><span id="line-699"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-700"></span><span>
</span><span id="line-701"></span><span class="hs-identifier">hideCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-702"></span><span class="hs-identifier">hideCaret</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-703"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;HideCaret&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_HideCaret</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-704"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h HideCaret&quot;</span><span>
</span><span id="line-705"></span><span>  </span><span class="hs-identifier">c_HideCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-706"></span><span>
</span><span id="line-707"></span><span class="hs-identifier">showCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-708"></span><span class="hs-identifier">showCaret</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-709"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;ShowCaret&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_ShowCaret</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-710"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ShowCaret&quot;</span><span>
</span><span id="line-711"></span><span>  </span><span class="hs-identifier">c_ShowCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-712"></span><span>
</span><span id="line-713"></span><span class="hs-comment">-- ToDo: allow arg2 to be NULL or {(HBITMAP)1}</span><span>
</span><span id="line-714"></span><span>
</span><span id="line-715"></span><span class="hs-identifier">createCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HBITMAP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-716"></span><span class="hs-identifier">createCaret</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">bm</span><span> </span><span class="hs-identifier">mb_w</span><span> </span><span class="hs-identifier">mb_h</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-717"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;CreateCaret&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-718"></span><span>    </span><span class="hs-identifier">c_CreateCaret</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-identifier">bm</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeNum</span><span> </span><span class="hs-identifier">mb_w</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeNum</span><span> </span><span class="hs-identifier">mb_h</span><span class="hs-special">)</span><span>
</span><span id="line-719"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h CreateCaret&quot;</span><span>
</span><span id="line-720"></span><span>  </span><span class="hs-identifier">c_CreateCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HBITMAP</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">INT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-721"></span><span>
</span><span id="line-722"></span><span class="hs-identifier">destroyCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-723"></span><span class="hs-identifier">destroyCaret</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-724"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;DestroyCaret&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_DestroyCaret</span><span>
</span><span id="line-725"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h DestroyCaret&quot;</span><span>
</span><span id="line-726"></span><span>  </span><span class="hs-identifier">c_DestroyCaret</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-727"></span><span>
</span><span id="line-728"></span><span class="hs-identifier">getCaretPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">POINT</span><span>
</span><span id="line-729"></span><span class="hs-identifier">getCaretPos</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-730"></span><span>  </span><span class="hs-identifier">allocaPOINT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">p_pt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-731"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetCaretPos&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetCaretPos</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-732"></span><span>  </span><span class="hs-identifier">peekPOINT</span><span> </span><span class="hs-identifier">p_pt</span><span>
</span><span id="line-733"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetCaretPos&quot;</span><span>
</span><span id="line-734"></span><span>  </span><span class="hs-identifier">c_GetCaretPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-735"></span><span>
</span><span id="line-736"></span><span class="hs-identifier">setCaretPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">POINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-737"></span><span class="hs-identifier">setCaretPos</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">x</span><span class="hs-special">,</span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-738"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;SetCaretPos&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetCaretPos</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span>
</span><span id="line-739"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetCaretPos&quot;</span><span>
</span><span id="line-740"></span><span>  </span><span class="hs-identifier">c_SetCaretPos</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-741"></span><span>
</span><span id="line-742"></span><span class="hs-comment">-- The remarks on SetCaretBlinkTime are either highly risible or very sad -</span><span>
</span><span id="line-743"></span><span class="hs-comment">-- depending on whether you plan to use this function.</span><span>
</span><span id="line-744"></span><span>
</span><span id="line-745"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-746"></span><span class="hs-comment">-- MSGs and event loops</span><span>
</span><span id="line-747"></span><span class="hs-comment">--</span><span>
</span><span id="line-748"></span><span class="hs-comment">-- Note that the following functions have to be reentrant:</span><span>
</span><span id="line-749"></span><span class="hs-comment">--</span><span>
</span><span id="line-750"></span><span class="hs-comment">--   DispatchMessage</span><span>
</span><span id="line-751"></span><span class="hs-comment">--   SendMessage</span><span>
</span><span id="line-752"></span><span class="hs-comment">--   UpdateWindow   (I think)</span><span>
</span><span id="line-753"></span><span class="hs-comment">--   RedrawWindow   (I think)</span><span>
</span><span id="line-754"></span><span class="hs-comment">--</span><span>
</span><span id="line-755"></span><span class="hs-comment">-- The following dont have to be reentrant (according to documentation)</span><span>
</span><span id="line-756"></span><span class="hs-comment">--</span><span>
</span><span id="line-757"></span><span class="hs-comment">--   GetMessage</span><span>
</span><span id="line-758"></span><span class="hs-comment">--   PeekMessage</span><span>
</span><span id="line-759"></span><span class="hs-comment">--   TranslateMessage</span><span>
</span><span id="line-760"></span><span class="hs-comment">--</span><span>
</span><span id="line-761"></span><span class="hs-comment">-- For Hugs (and possibly NHC too?) this is no big deal.</span><span>
</span><span id="line-762"></span><span class="hs-comment">-- For GHC, you have to use casm_GC instead of casm.</span><span>
</span><span id="line-763"></span><span class="hs-comment">-- (It might be simpler to just put all this code in another</span><span>
</span><span id="line-764"></span><span class="hs-comment">-- file and build it with the appropriate command line option...)</span><span>
</span><span id="line-765"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-766"></span><span>
</span><span id="line-767"></span><span class="hs-comment">-- type MSG =</span><span>
</span><span id="line-768"></span><span class="hs-comment">--   ( HWND   -- hwnd;</span><span>
</span><span id="line-769"></span><span class="hs-comment">--   , UINT   -- message;</span><span>
</span><span id="line-770"></span><span class="hs-comment">--   , WPARAM -- wParam;</span><span>
</span><span id="line-771"></span><span class="hs-comment">--   , LPARAM -- lParam;</span><span>
</span><span id="line-772"></span><span class="hs-comment">--   , DWORD  -- time;</span><span>
</span><span id="line-773"></span><span class="hs-comment">--   , POINT  -- pt;</span><span>
</span><span id="line-774"></span><span class="hs-comment">--   )</span><span>
</span><span id="line-775"></span><span>
</span><span id="line-776"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">LPMSG</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Addr</span><span>
</span><span id="line-777"></span><span>
</span><span id="line-778"></span><span class="hs-identifier">allocaMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-779"></span><span class="hs-identifier">allocaMessage</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-number">48</span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span class="hs-pragma">{-# LINE 780 &quot;libraries\\Win32\\Graphics\\Win32\\Window.hsc&quot; #-}</span><span>
</span><span id="line-780"></span><span>
</span><span id="line-781"></span><span class="hs-comment">-- A NULL window requests messages for any window belonging to this thread.</span><span>
</span><span id="line-782"></span><span class="hs-comment">-- a &quot;success&quot; value of 0 indicates that WM_QUIT was received</span><span>
</span><span id="line-783"></span><span>
</span><span id="line-784"></span><span class="hs-identifier">getMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-785"></span><span class="hs-identifier">getMessage</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-786"></span><span>  </span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIf</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==</span><span> </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-string">&quot;GetMessage&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-787"></span><span>    </span><span class="hs-identifier">c_GetMessage</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-788"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">res</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span>
</span><span id="line-789"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h GetMessageW&quot;</span><span>
</span><span id="line-790"></span><span>  </span><span class="hs-identifier">c_GetMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LONG</span><span>
</span><span id="line-791"></span><span>
</span><span id="line-792"></span><span class="hs-comment">-- A NULL window requests messages for any window belonging to this thread.</span><span>
</span><span id="line-793"></span><span class="hs-comment">-- Arguably the code block shouldn't be a 'safe' one, but it shouldn't really</span><span>
</span><span id="line-794"></span><span class="hs-comment">-- hurt.</span><span>
</span><span id="line-795"></span><span>
</span><span id="line-796"></span><span class="hs-identifier">peekMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-797"></span><span class="hs-identifier">peekMessage</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">filterMin</span><span> </span><span class="hs-identifier">filterMax</span><span> </span><span class="hs-identifier">remove</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-798"></span><span>  </span><span class="hs-identifier">failIf_</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==</span><span> </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-string">&quot;PeekMessage&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-799"></span><span>    </span><span class="hs-identifier">c_PeekMessage</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">filterMin</span><span> </span><span class="hs-identifier">filterMax</span><span> </span><span class="hs-identifier">remove</span><span>
</span><span id="line-800"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h PeekMessageW&quot;</span><span>
</span><span id="line-801"></span><span>  </span><span class="hs-identifier">c_PeekMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LONG</span><span>
</span><span id="line-802"></span><span>
</span><span id="line-803"></span><span class="hs-comment">-- Note: you're not supposed to call this if you're using accelerators</span><span>
</span><span id="line-804"></span><span>
</span><span id="line-805"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h TranslateMessage&quot;</span><span>
</span><span id="line-806"></span><span>  </span><span class="hs-identifier">translateMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span class="hs-identifier">updateWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-809"></span><span class="hs-identifier">updateWindow</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-810"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;UpdateWindow&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_UpdateWindow</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-811"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h UpdateWindow&quot;</span><span>
</span><span id="line-812"></span><span>  </span><span class="hs-identifier">c_UpdateWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-813"></span><span>
</span><span id="line-814"></span><span class="hs-comment">-- Return value of DispatchMessage is usually ignored</span><span>
</span><span id="line-815"></span><span>
</span><span id="line-816"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h DispatchMessageW&quot;</span><span>
</span><span id="line-817"></span><span>  </span><span class="hs-identifier">dispatchMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPMSG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LONG</span><span>
</span><span id="line-818"></span><span>
</span><span id="line-819"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h SendMessageW&quot;</span><span>
</span><span id="line-820"></span><span>  </span><span class="hs-identifier">sendMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPARAM</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LRESULT</span><span>
</span><span id="line-821"></span><span>
</span><span id="line-822"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-823"></span><span>
</span><span id="line-824"></span><span class="hs-comment">-- ToDo: figure out reentrancy stuff</span><span>
</span><span id="line-825"></span><span class="hs-comment">-- ToDo: catch error codes</span><span>
</span><span id="line-826"></span><span class="hs-comment">--</span><span>
</span><span id="line-827"></span><span class="hs-comment">-- ToDo: how to send HWND_BROADCAST to PostMessage</span><span>
</span><span id="line-828"></span><span class="hs-comment">-- %fun PostMessage       :: MbHWND -&gt; WindowMessage -&gt; WPARAM -&gt; LPARAM -&gt; IO ()</span><span>
</span><span id="line-829"></span><span class="hs-comment">-- %fun PostQuitMessage   :: Int -&gt; IO ()</span><span>
</span><span id="line-830"></span><span class="hs-comment">-- %fun PostThreadMessage :: DWORD -&gt; WindowMessage -&gt; WPARAM -&gt; LPARAM -&gt; IO ()</span><span>
</span><span id="line-831"></span><span class="hs-comment">-- %fun InSendMessage     :: IO Bool</span><span>
</span><span id="line-832"></span><span>
</span><span id="line-833"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-834"></span><span class="hs-comment">-- End</span><span>
</span><span id="line-835"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-836"></span></pre></body></html>